<?php

namespace Apps\AppApi;

use PhalconPlus\Common\BaseModule;
use PhalconPlus\Api\Common\HandleApiBase;
use Phalcon\Mvc\ModuleDefinitionInterface;
use PhalconPlus\Api\Common\ResultStatus;


class Module extends BaseModule implements ModuleDefinitionInterface
{
    const DIR = __DIR__;
    /**
     * Registers the module-only services
     * @param \Phalcon\DiInterface $di
     */
    public function registerServices(\Phalcon\DiInterface $di)
    {
    	parent::registerServices($di);
    	$config = $this->config;
    	$versionmin=$config->api->versionmin;
    	if(isset($_POST['version'])){
    		$version = $_POST['version'];
    	} 
    	if(!empty($version)){
    		if($version < $versionmin){//版本不可用  VersionError
    			 $arr = array(
    			 "status"=>"701",
    			 "result"=>'null',
    			 "errmsg"=>"版本不可用",
    			 "timestamp" => time(),
    			 "attach"=>"",
    			 "sign"=>""
    			 );
    			 echo json_encode($arr);
    			exit; 
    		}
    	} 
		/////////////////////////////////////////
        //$config = $this->config;

    	$di['apiConfig'] = function() use ($config) {
    		return $config->api;
    	};

    }

}
